package com.lzh.farmersshop.controller.admin;


import com.lzh.farmersshop.util.Result;
import lombok.extern.slf4j.Slf4j;
import com.lzh.farmersshop.entity.Evaluation;
import com.lzh.farmersshop.service.EvaluationService;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.io.Serializable;
import java.util.Date;
import java.util.List;

/**
 * (Evaluation)表控制层
 *
 * @author makejava
 * @since 2024-01-04 15:41:50
 */
@Slf4j
@RestController
@RequestMapping("admin/evaluation")
@Transactional(rollbackFor = Exception.class)
public class EvaluationController {
    /**
     * 服务对象
     */
    @Resource
    private EvaluationService evaluationService;

    /**
     * 分页查询所有数据
     *
     * @param evaluation 查询实体
     * @return 所有数据
     */
    @GetMapping("selectAll")
    public Result selectAll(Evaluation evaluation,Integer page,Integer limit) {
        if (limit == null || page == null) {
            return Result.failure("limit和page不能为空");
        }
        return evaluationService.selectAll(evaluation,page,limit);
    }

    /**
     * 修改数据
     *
     * @param evaluation 实体对象
     * @return 修改结果
     */
    @PostMapping("update")
    public Result update(Evaluation evaluation) {
        if (evaluation==null){
            return Result.failure("参数不能为空");
        }

        evaluation.setHftime(new Date());

        if (evaluationService.updateById(evaluation)){
            return Result.success("回复成功");
        }
        return Result.failure("回复失败");
    }


}

